//
//  AnimationModel.m
//  DeepBreathing
//
//  Created by rimi on 15/12/22.
//  Copyright © 2015年 rimi. All rights reserved.
//

#import "AnimationModel.h"
#import <UIKit/UIKit.h>

static const CGFloat height1_ = 372.f;
static const CGFloat height2_ = 767.f;
static const CGFloat width_ = 375.f;

@interface AnimationModel ()

@property (nonatomic, strong) UIBezierPath * fromPath;
@property (nonatomic, strong) UIBezierPath * toPath;
@property (nonatomic, assign) NSTimeInterval pathAnimationDuration;

@property (nonatomic, assign) NSTimeInterval flipAnimationDuration;

@property (nonatomic, strong) NSArray * orangeColors;
@property (nonatomic, strong) NSArray * purpleColors;
@property (nonatomic, strong) NSArray * fromRedColors;
@property (nonatomic, strong) NSArray * toRedColors;

@end

@implementation AnimationModel

- (NSTimeInterval)pathAnimationDuration
{
    return 0.68f;
}

- (NSTimeInterval)flipAnimationDuration
{
    return 0.8f;
}

- (UIBezierPath *)fromPath
{
    if (!_fromPath) {
        _fromPath = ({
            
            UIBezierPath * fromPath = [UIBezierPath bezierPath];
            [fromPath moveToPoint:CGPointZero];
            [fromPath addLineToPoint:CGPointMake(0, height1_)];
            [fromPath addQuadCurveToPoint:CGPointMake(width_, height1_) controlPoint:CGPointMake(width_/2, 490)];
            [fromPath addLineToPoint:CGPointMake(width_, 0)];
            [fromPath closePath];
            fromPath;
            
        });
    }
    return _fromPath;
}

- (UIBezierPath *)toPath
{
    if (!_toPath) {
        _toPath = ({
            
            UIBezierPath * toPath = [UIBezierPath bezierPath];
            [toPath moveToPoint:CGPointZero];
            [toPath addLineToPoint:CGPointMake(0, height2_)];
            [toPath addQuadCurveToPoint:CGPointMake(width_, height2_) controlPoint:CGPointMake(width_/2, 667)];
            [toPath addLineToPoint:CGPointMake(width_, 0)];
            [toPath closePath];
            toPath;
            
        });
    }
    return _toPath;
}

- (NSArray *)orangeColors
{
    if (!_orangeColors) {
        _orangeColors = @[(__bridge id)[UIColor colorWithRed:250.f/255.f green:159.f/255 blue:81.f/255 alpha:1].CGColor, (__bridge id)[UIColor colorWithRed:249.f/255 green:210.f/255 blue:102.f/255 alpha:1].CGColor];
    }
    return _orangeColors;
}

- (NSArray *)purpleColors
{
    if (!_purpleColors) {
        _purpleColors = @[(__bridge id)[UIColor colorWithRed:43.f/255.f green:40.f/255.f blue:143.f/255.f alpha:1].CGColor, (__bridge id)[UIColor colorWithRed:107.f/255.f green:32.f/255.f blue:229.f/255 alpha:1].CGColor];
    }
    return _purpleColors;
}

- (NSArray *)fromRedColors
{
    if (!_fromRedColors) {
        _fromRedColors = @[(__bridge id)[UIColor colorWithRed:202.f/255 green:96.f/255 blue:209.f/255 alpha:1].CGColor,(__bridge id)[UIColor colorWithRed:255.f/255 green:122.f/255 blue:72.f/255 alpha:1].CGColor];
    }
    return _fromRedColors;
}

- (NSArray *)toRedColors
{
    if (!_toRedColors) {
        _toRedColors = @[(__bridge id)[UIColor colorWithRed:244.f/255 green:23.f/255 blue:23.f/255 alpha:1].CGColor,(__bridge id)[UIColor colorWithRed:231.f/255 green:15.f/255 blue:135.f/255 alpha:1].CGColor];
    }
    return _toRedColors;
}

@end